let settings = filter(tohtml#GetUserSettings(),'type(v:val)==type(0)')
let s:sorted_settings = sort(keys(settings))

function! Get2htmlSettings(ArgLead, CmdLine, CursorPos)
  let first_settings = join(split(a:ArgLead, '\s\+', 1)[:-2])
  echomsg "first_setttings=" first_settings "and is of type" type(first_settings)
  if !empty(first_settings)
    let first_settings .= ' '
  endif
  return map(filter(copy(s:sorted_settings), 'v:val =~ "'.get(split(a:ArgLead, '\s\+', 1), -1, "").'"'), 'first_settings.v:val')
endfun

let newopts_str = input("New options: ", "", 'customlist,Get2htmlSettings')
let new_options = sort(split(newopts_str))

let existing_files  = glob('options_test/*.html',  1, 1)
let existing_files += glob('options_test/*.xhtml', 1, 1)

let smore = &more
set nomore

for fname in existing_files
  "let components = split(fnamemodify(fname, ":t:r"), '[-+][^-+]\+\zs')
  "let components = map(components, 'v:val =~ "^+" ? "1" : "0"')
  let components = split(fnamemodify(fname, ":t:r"), '[01]\zs')
  for newopt in new_options
    let idx=match(s:sorted_settings, newopt)
    call insert(components, string(settings[newopt] != 0), idx)
  endfor
  let newFname = fnamemodify(fname, ":h").'/'.join(components, "").'.'.fnamemodify(fname, ":e")
  echo '!hg rename --' fname newFname
  silent exec '!hg rename --' fname newFname
endfor

let &more = smore
